import layoutHeaderAside from '@/layout/header-aside'
import i18n from '@/i18n';

// 由于懒加载页面太多的话会造成webpack热更新太慢，所以开发环境不使用懒加载，只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)

/**
 * 在主框架内显示
 */
const frameIn = [
  {
    path: '/',
    redirect: { name: 'index' },
    component: layoutHeaderAside,
    children: [
      // 首页
      {
        path: 'index',
        name: 'index',
        meta: {
          title: i18n.t('page.nav.home'),
          auth: true
        },
        component: _import('system/index')
      },
      // 系统 前端日志
      {
        path: 'log',
        name: 'log',
        meta: {
          title: '前端日志',
          auth: true
        },
        component: _import('system/log')
      },
       // 系统 消息
       {
        path: 'bell',
        name: 'bell',
        meta: {
          title: i18n.t('page.nav.notice'),
          auth: true
        },
        component: _import('system/bell')
      },
      // 刷新页面 必须保留
      {
        path: 'refresh',
        name: 'refresh',
        hidden: true,
        component: _import('system/function/refresh')
      },
      // 页面重定向 必须保留
      {
        path: 'redirect/:route*',
        name: 'redirect',
        hidden: true,
        component: _import('system/function/redirect')
      }
    ]
  },
  // {
  //   path: '/demo',
  //   component: layoutHeaderAside,
  //   children: (pre => [
  //     { path: 'i18n', name: `${pre}/i18n`, component: _import(`${pre}/i18n`), meta: { auth: true, title: '国际化示例' } },
  //   ])('demo')
  // },

  // {
  //   path: '/trade',
  //   name: '/trade',
  //   meta: {},
  //   component: layoutHeaderAside,
  //   children: (pre => [
  //     { path: 'detail', name: 'trade-detail', component: _import('trade/detail'), meta: { auth: true, title: '交易查询', cache: true } },
  //     { path: 'track', name: pre + 'track', component: _import('trade/track'), meta: { auth: true, title: '交易跟踪' } },
  //     { path: 'refund', name: pre + 'refund', component: _import('trade/refund'), meta: { auth: true, title: '交易退款' } },
  //     { path: 'logistics', name: pre + 'logistics', component: _import('trade/logistics'), meta: { auth: true, title: '运单管理' } },
  //     { path: 'auth', name: pre + 'auth', component: _import('trade/auth'), meta: { auth: true, title: '预授权交易' } },
  //   ])('/trade/'),
  // },

  // {
  //   path: '/trans',
  //   name: '/trans',
  //   meta: {},
  //   component: layoutHeaderAside,
  //   children: (pre => [
  //     { path: 'dis', name: pre + 'dis', component: _import('trans/dis'), meta: { auth: true, title: '拒付单' } },
  //     { path: 'lookInto', name: pre + 'lookInto', component: _import('trans/lookInto'), meta: { auth: true, title: '调查单' } },
  //     { path: 'complaint', name: pre + 'complaint', component: _import('trans/complaint'), meta: { auth: true, title: '投诉单' } },
  //   ])('/trans/'),
  // },

  // {
  //   path: '/settle',
  //   name: '/settle',
  //   meta: {},
  //   component: layoutHeaderAside,
  //   children: (pre => [
  //     { path: 'account', name: pre + 'account', component: _import('settle/account'), meta: { auth: true, title: '交易账户' } },
  //     { path: 'operatetrade', name: pre + 'operatetrade', component: _import('settle/operatetrade'), meta: { auth: true, title: '事件订单' } },
  //     { path: 'detail', name: pre + 'detail', component: _import('settle/detail'), meta: { auth: true, title: '出入账管理' } },
  //     { path: 'withdraw', name: pre + 'withdraw', component: _import('settle/withdraw'), meta: { auth: true, title: '提现管理' } },
  //     { path: 'order', name: pre + 'order', component: _import('settle/order'), meta: { auth: true, title: '核算订单' } },
  //     { path: 'report', name: pre + 'report', component: _import('settle/report'), meta: { auth: true, title: '交易报告' } },
  //   ])('/settle/'),
  // },

  //  {
  //   path: '/sys',
  //   name: '/sys',
  //   meta: {},
  //   component: layoutHeaderAside,
  //   children: (pre => [
  //     { path: 'node', name: pre + 'node', component: _import('sys/node'), meta: { auth: true, title: '节点管理' } },
  //     { path: 'user', name: pre + 'user', component: _import('sys/user'), meta: { auth: true, title: '用户管理' } },
  //     { path: 'role', name: pre + 'role', component: _import('sys/role'), meta: { auth: true, title: '角色管理' } },
  //     { path: 'terminal', name: pre + 'terminal', component: _import('sys/terminal'), meta: { auth: true, title: '终端管理' } },
  //     { path: 'mail', name: pre + 'mail', component: _import('sys/mail'), meta: { auth: true, title: '邮件管理' } },
  //   ])('/sys/'),
  // },

]

/**
 * 在主框架之外显示
 */
const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    component: _import('system/login')
  },
  // 修改密码
  {
    path: '/change-password',
    name: 'change-password',
    component: _import('system/change-password')
  },
  {
    path: '/register',
    name: 'register',
    component: _import('system/register')
  },
  {
    path: '/registerStart',
    name: 'registerStart',
    component: _import('system/registerStart')
  },
  {
    path: '/retrievePassword',
    name: 'retrievePassword',
    component: _import('system/retrievePassword')
  },
  {
    path: '/registerAnew',
    name: 'registerAnew',
    component: _import('system/registerAnew')
  },
  {
    path: '/registerStait',
    name: 'registerStait',
    component: _import('system/registerStait')
  }
]

/**
 * 错误页面
 */
const errorPage = [
  {
    path: '*',
    name: '404',
    component: _import('system/error/404')
  }
]

// 导出需要显示菜单的
export const frameInRoutes = frameIn

// 重新组织后导出
export default [
  ...frameIn,
  ...frameOut,
  ...errorPage
]
